package hanjia;

import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;

/**
 * Description:
 * Author:    Dane
 * CreateTime:2025/2/10-下午3:23
 * Since  :   1.0
 * Version:   1.0
 */


public class LeetCode349 {

    public int[] intersection(int[] nums1, int[] nums2) {
        HashSet<Integer> pre = new HashSet<>();
        HashSet<Integer> result = new HashSet<>();

        for (int i:nums1){
            pre.add(i);
        }
        for (int i:nums2){
            if (pre.contains(i)){
                result.add(i);
            }
        }


        return result.stream().mapToInt(Integer::intValue).toArray();


    }
}
